using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Bll
{
	class CBidHistoryManage
	{
		public static CBidHistory CreateHistory()
       {      
           return   new CBidHistory();
       }
	
		public static CBidHistory Save(CBidHistory bidhistory)
		{
			try
			{
				int num = BLL.SqlHelper.ExecuteNonQuery(CConnection.getConnString(), "sp_AddBidHistory", bidhistory.ID, bidhistory.bidID, bidhistory.sellerID, bidhistory.commodityID, bidhistory.price, bidhistory.time, bidhistory.name, bidhistory.pic, bidhistory.status);
             
				if(0==num)
					return null;
				return bidhistory;

			}
			catch (Exception e)
			{
				return null;
			}
		}
	
		public static bool Update(CBidHistory bidhistory)
		{
	
			try
			{
				int num = BLL.SqlHelper.ExecuteNonQuery(CConnection.getConnString(), "sp_SaveBidHistory", bidhistory.ID, bidhistory.bidID, bidhistory.sellerID, bidhistory.commodityID, bidhistory.price, bidhistory.time, bidhistory.name, bidhistory.pic, bidhistory.status);
				if (0 == num)
					return false;
				return true;
			}
			catch (Exception e)
			{
				return false ;
			}
		}
	
		public static bool Delete(CBidHistory bidhistory)
		{
	
			try
			{
				int num = BLL.SqlHelper.ExecuteNonQuery(CConnection.getConnString(), "sp_RemoveBidHistory", bidhistory.ID);
				if (0 == num)
					return false;
				return true;
	
			}
			catch (Exception e)
			{
				return false;
			}   
		}
	
		static CBidHistory GetBidHistory(String ID)
		{
			try
			{
				SqlDataReader reader= BLL.SqlHelper.ExecuteReader(CConnection.getConnString(), "sp_GetBidHistory", ID);
				if (reader.NextResult())
				{ 
                   
					CBidHistory bidHistory=new CBidHistory();
					bidHistory.bidID = reader["bidID"].ToString();
					bidHistory.commodityID = reader["commodityID"].ToString();
					//bidHistory.price = reader["price"]
					//bidHistory.time = reader["time"]
					bidHistory.name = reader["name"].ToString();
					bidHistory.pic = reader["pic"].ToString();
					//bidHistory.status = reader["status"]
					reader.Close();
					return bidHistory;
				}
				reader.Close();
				return null;
			}
			catch (Exception e)
			{

				//reader.Close();
               return null;
			}
		}
	}
}